USE [safe_manage]
GO

/****** Object:  Table [dbo].[accident_type]    Script Date: 08/29/2012 21:36:13 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[accident_type](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ACCIDENT_TYPE] [varchar](100) NOT NULL,
	[DEPARTMENT1_ID] [int] NULL,
 CONSTRAINT [PK_accident_type] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

USE [safe_manage]
GO

/****** Object:  Table [dbo].[deleted_defect]    Script Date: 09/01/2012 14:14:28 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[deleted_defect](
	[ID] [int] NOT NULL,
	[DEFECT_TYPE_ID] [int] NOT NULL,
	[LOSS] [varchar](2000) NOT NULL,
	[REASON] [varchar](5000) NOT NULL,
	[DUTY] [varchar](5000) NULL,
	[TEAM] [varchar](500) NULL,
	[DEFECT_TIME] [datetime] NULL,
	[DEFECT_WRITE_TIME] [datetime] NULL,
	[DEFECT_WRITE_USER_ID] [int] NULL,
 CONSTRAINT [PK_deleted_defect] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

USE [safe_manage]
GO

/****** Object:  Table [dbo].[deleted_tendency]    Script Date: 09/01/2012 14:31:21 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[deleted_tendency](
	[ID] [int] NOT NULL,
	[TENDENCY_TYPE_ID] [int] NOT NULL,
	[LOSS] [varchar](2000) NOT NULL,
	[REASON] [varchar](5000) NOT NULL,
	[DUTY] [varchar](5000) NULL,
	[TEAM] [varchar](500) NULL,
	[TENDENCY_TIME] [datetime] NULL,
	[TENDENCY_WRITE_TIME] [datetime] NULL,
	[TENDENCY_WRITE_USER_ID] [int] NULL,
 CONSTRAINT [PK_DELETED_TENDENCY] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

USE [safe_manage]
GO

/****** Object:  Table [dbo].[deleted_shutdown]    Script Date: 09/01/2012 14:42:55 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[deleted_shutdown](
	[ID] [int] NOT NULL,
	[SHUTDOWN_TYPE_ID] [int] NOT NULL,
	[LOSS] [varchar](2000) NOT NULL,
	[REASON] [varchar](5000) NOT NULL,
	[DUTY] [varchar](5000) NOT NULL,
	[TEAM] [varchar](500) NOT NULL,
	[PERIOD_START] [datetime] NOT NULL,
	[PERIOD_END] [datetime] NOT NULL,
	[SHUTDOWN_WRITE_TIME] [datetime] NULL,
	[SHUTDOWN_WRITE_USER_ID] [int] NULL,
 CONSTRAINT [PK_deleted_shutdown] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

insert into [dbo].[accident_type] (ACCIDENT_TYPE, DEPARTMENT1_ID) values('生产', (select ID from department1 where DEPARTMENT1_NAME = '生产调度处' ))
go
insert into [dbo].[accident_type] (ACCIDENT_TYPE, DEPARTMENT1_ID) values('工艺技术', (select ID from department1 where DEPARTMENT1_NAME = '技术质量处' ))
go
insert into [dbo].[accident_type] (ACCIDENT_TYPE, DEPARTMENT1_ID) values('设备', (select ID from department1 where DEPARTMENT1_NAME = '设备动力处' ))
go
insert into [dbo].[accident_type] (ACCIDENT_TYPE, DEPARTMENT1_ID) values('交通', (select ID from department1 where DEPARTMENT1_NAME = '保卫处' ))
go
insert into [dbo].[accident_type] (ACCIDENT_TYPE, DEPARTMENT1_ID) values('火灾爆炸', (select ID from department1 where DEPARTMENT1_NAME = '消防支队' ))
go
insert into [dbo].[accident_type] (ACCIDENT_TYPE, DEPARTMENT1_ID) values('放射、人身伤害及环保安全环保', (select ID from department1 where DEPARTMENT1_NAME = 'HSE管理处' ))
go

insert into role_auth(AUTH_TYPE, ROLE_ID, PROCESS_METHOD, HAS_RIGHT) values(1, 11, 2, 1)
go
insert into role_auth(AUTH_TYPE, ROLE_ID, PROCESS_METHOD, HAS_RIGHT) values(2, 11, 2, 1)
go
insert into role_auth(AUTH_TYPE, ROLE_ID, PROCESS_METHOD, HAS_RIGHT) values(3, 11, 2, 1)
go
insert into role_auth(AUTH_TYPE, ROLE_ID, PROCESS_METHOD, HAS_RIGHT) values(4, 11, 2, 1)
go

alter table deleted_problem add PROCESSING_BY_CHUSHI bit default 0
go